package com.liangzhong.model.youngTrain
{
	import com.liangzhong.model.youngTrain.vo.PlayerChildInfoVo;
	import com.liangzhong.model.youngTrain.vo.YoungTrainInfoVo;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;

	/**
	 *青训营管理 
	 * @author lake
	 * 
	 */	
	public class YoungTrainDataManager extends EventDispatcher
	{
		/**
		 *青训营基本信息 
		 */		
		public var youngTrainInfoVo 	:YoungTrainInfoVo = new YoungTrainInfoVo();
		/**
		 *当前出售的球星颜色 
		 */		
		public var curSaleColor			:int = 1;
		/**
		 * 签约的球童颜色
		 */		
		public var saleColors				:Array = [];
		/**
		 *出售或者签约请求的index 
		 */		
		public var saleOrgetChildIndexs 	:Array = [];
		/**
		 *青训营升级下一级增加的球童数描述数组 
		 */		
		public var nextAddCNums			:Array = [0,0,1,0,0,1,0,0,1,0];
		/**
		 *青训营升级下一级开放球童颜色
		 */		
		public var nextCColors			:Array = ["蓝色","紫色","紫色","紫色","紫色","紫色","橙色","橙色","橙色","橙色"];
		/**
		 *购买一次每天生产球童数价格 W 
		 */		
		private var buyNumPrices			:Array = [30,80,80,80,80,80,1000,1000,3600,9000];
		/**
		 *球童出售价格 W
		 * 灰 -》 黑 
		 */		
		private var salePrices			:Array = [0,10,30,80,1000,3600,12000,12000];
		/**
		 *购买场上球童数 
		 * 一次 点券
		 */		
		private var openNumPrices		:Array = [10000,20000,30000,40000,50000,80000,80000,80000,80000];
		/**
		 *加速欧元消耗 W
		 * 灰 - 黑 
		 */		
		private var growAccPrices		:Array = [1,13,38,100,1250,4500,15000];
		
		public function YoungTrainDataManager()
		{
		}
		/**
		 *解析信息 
		 * @param data
		 * 
		 */		
		public function parseBaseInfo(data:Object):void
		{
			youngTrainInfoVo.parseBaseInfo(data);
			this.dispatchEvent(new Event(Event.CHANGE));
		}
		/**
		 *添加球童 
		 * @param obj
		 * 
		 */		
		public function addPlayerChild(obj :Object):void
		{
			youngTrainInfoVo.addPlayerChild(obj);
			this.dispatchEvent(new Event(Event.CHANGE));
		}
		/**
		 *删除球童通过index 
		 * @param index
		 * 
		 */		
		public function removePlayerChildByIndex(index :int):void
		{
			var i :int = 0;
			for each(var cinfo:PlayerChildInfoVo in youngTrainInfoVo.playerChildList)
			{
				if(cinfo.index == index)
				{
					youngTrainInfoVo.playerChildList.splice(i,1);
					break;
				}
				i ++;
			}
		}
		/**
		 *设置球员完成状态（快速完成） 
		 * @param index
		 * 
		 */		
		public function setPlayerChildComplete(index :int):void
		{
			youngTrainInfoVo.setPlayerChildComplete(index);
			this.dispatchEvent(new Event(Event.CHANGE));
		}
		/**
		 *得到出售价格 
		 * @return 
		 * 
		 */		
		public function get salePrice():int
		{
			return salePrices[curSaleColor - 1];
		}
		/**
		 *得到出售价格 
		 * @return 
		 * 
		 */	
		public function getSalePrice(color :int):int
		{
			return salePrices[color - 1];
		}
		/**
		 *增加生产次数 价格
		 * @return 
		 * 
		 */		
		public function get addNumPrice():int
		{
			return buyNumPrices[youngTrainInfoVo.level - 1];
		}
		/**
		 * 增加场上球童数价格
		 * @return 
		 * 
		 */		
		public function get openNumPrice():int
		{
			return openNumPrices[youngTrainInfoVo.numcashpoint];
		}
		/**
		 *获取加速球童价格 
		 * @return 
		 */		
		public function getGrowAccPrice(color :int):int
		{
			return growAccPrices[color-1];
		}
		/**
		 *获取球童颜色通过index 
		 * @param index
		 * @return 
		 * 
		 */		
		public function getChildColorByIndex(index :int):int
		{
			for each(var cinfo:PlayerChildInfoVo in youngTrainInfoVo.playerChildList)
			{
				if(cinfo.index == index)
				{
					return cinfo.color;
				}
			}
			return 1;
		}
	}
}